# Emitter

<div class="api-docs__separator" data-reactroot="">

---

</div><div class="api-docs__import" data-reactroot="">

```ts
import { Emitter } from "@hyper-fetch/sockets";
```

</div><div class="api-docs__section">

## Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:8](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L8)

</p><div class="api-docs__section">

## Parameters

</div>
<div class="api-docs__parameters">
<table>
<thead><tr><th>Name</th><th>Details</th></tr></thead>
<tbody><tr param-data="socket"><td class="api-docs__param-name required">

### socket

`Required`

</td><td class="api-docs__param-type">

`Socket<ClientType>`

</td></tr><tr param-data="emitterOptions"><td class="api-docs__param-name required">

### emitterOptions

`Required`

</td><td class="api-docs__param-type">

`EmitterOptionsType<ExtractEmitterOptionsType<ClientType>>`

</td></tr><tr param-data="dump"><td class="api-docs__param-name optional">

### dump

`Optional`

</td><td class="api-docs__param-type">

`Partial<Emitter<RequestDataType, ResponseDataType, ClientType, MappedData>>`

</td></tr><tr param-data="dataMapper"><td class="api-docs__param-name optional">

### dataMapper

`Optional`

</td><td class="api-docs__param-type">

`(data: RequestDataType) => MappedData`

</td></tr></tbody></table></div><div class="api-docs__section">

## Properties

</div><div class="api-docs__properties"><div class="api-docs__property" property-data="data"><h3 class="api-docs__name">

### `data`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:11](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L11)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
RequestDataType;
```

</div><hr/></div><div class="api-docs__property" property-data="emitterOptions"><h3 class="api-docs__name">

### `emitterOptions`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:16](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L16)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
EmitterOptionsType<ExtractEmitterOptionsType<ClientType>>;
```

</div><hr/></div><div class="api-docs__property" property-data="name"><h3 class="api-docs__name">

### `name`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:9](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L9)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
string;
```

</div><hr/></div><div class="api-docs__property" property-data="options"><h3 class="api-docs__name">

### `options`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:12](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L12)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
ExtractEmitterOptionsType<ClientType>;
```

</div><hr/></div><div class="api-docs__property" property-data="socket"><h3 class="api-docs__name">

### `socket`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:15](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L15)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
Socket<ClientType>;
```

</div><hr/></div><div class="api-docs__property" property-data="timeout"><h3 class="api-docs__name">

### `timeout`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:10](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L10)

</p><div class="api-docs__section">

#### Type

</div><div class="api-docs__property-type">

```ts
number;
```

</div><hr/></div></div><div class="api-docs__section">

## Methods

</div><div class="api-docs__methods"><div class="api-docs__method" method-data="dataMapper"><h3 class="api-docs__name">

### `dataMapper()`

</h3><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:18](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L18)

</p><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
(data: RequestDataType) => MappedData;
```

</div><hr/></div><div class="api-docs__method" method-data="clone"><h3 class="api-docs__name">

### `clone()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
clone<NewRequestDataType, MapperData>(config, mapper);
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:46](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L46)

</p><div class="api-docs__section">

#### Parameters

</div>
<div class="api-docs__parameters">
<table>
<thead><tr><th>Name</th><th>Details</th></tr></thead>
<tbody><tr param-data="config"><td class="api-docs__param-name optional">

#### config

`Optional`

</td><td class="api-docs__param-type">

`Partial<EmitterCloneOptionsType<NewRequestDataType, ExtractEmitterOptionsType<ClientType>>>`

</td></tr><tr param-data="mapper"><td class="api-docs__param-name optional">

#### mapper

`Optional`

</td><td class="api-docs__param-type">

`(data: NewRequestDataType) => MapperData`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
Emitter<NewRequestDataType, ResponseDataType, ClientType, MapperData>;
```

</div><hr/></div><div class="api-docs__method" method-data="emit"><h3 class="api-docs__name">

### `emit()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
emit(options, ack);
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:67](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L67)

</p><div class="api-docs__section">

#### Parameters

</div>
<div class="api-docs__parameters">
<table>
<thead>
<tr><th>Name</th><th>Details</th></tr>
</thead><tbody>
<tr param-data="options"><td class="api-docs__param-name optional">

#### options

`Optional`

</td><td class="api-docs__param-type">

`Partial<EmitterCloneOptionsType<RequestDataType, ExtractEmitterOptionsType<ClientType>>>`

</td></tr><tr param-data="ack"><td class="api-docs__param-name optional">

#### ack

`Optional`

</td><td class="api-docs__param-type">

`(error: Error, response: ResponseDataType) => void`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
string;
```

</div><hr/></div><div class="api-docs__method" method-data="setData"><h3 class="api-docs__name">

### `setData()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
setData(data);
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:35](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L35)

</p><div class="api-docs__section">

#### Parameters

</div>
<div class="api-docs__parameters">
<table>
<thead><tr><th>Name</th><th>Details</th></tr></thead>
<tbody><tr param-data="data"><td class="api-docs__param-name required">

#### data

`Required`

</td><td class="api-docs__param-type">

`RequestDataType`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
any;
```

</div><hr/></div><div class="api-docs__method" method-data="setDataMapper"><h3 class="api-docs__name">

### `setDataMapper()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
setDataMapper<MapperData>(mapper);
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:42](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L42)

</p><div class="api-docs__section">

#### Parameters

</div>
<div class="api-docs__parameters">
<table>
<thead><tr><th>Name</th><th>Details</th></tr></thead>
<tbody><tr param-data="mapper"><td class="api-docs__param-name required">

#### mapper

`Required`

</td><td class="api-docs__param-type">

`(data: RequestDataType) => MapperData`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
Emitter<RequestDataType, ResponseDataType, ClientType, MapperData>;
```

</div><hr/></div><div class="api-docs__method" method-data="setOptions"><h3 class="api-docs__name">

### `setOptions()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
setOptions(options);
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:27](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L27)

</p><div class="api-docs__section">

#### Parameters

</div>
<div class="api-docs__parameters">
<table>
<thead><tr><th>Name</th><th>Details</th></tr></thead>
<tbody><tr param-data="options"><td class="api-docs__param-name required">

#### options

`Required`

</td><td class="api-docs__param-type">

`ExtractEmitterOptionsType<ClientType>`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
Emitter<RequestDataType, ResponseDataType, ClientType, MappedData>;
```

</div><hr/></div><div class="api-docs__method" method-data="setTimeout"><h3 class="api-docs__name">

### `setTimeout()`

</h3><div class="api-docs__section">

#### Preview

</div><div class="api-docs__preview fn">

```ts
setTimeout(timeout);
```

</div><div class="api-docs__section">

#### Description

</div><div class="api-docs__description"><span class="api-docs__do-not-parse">

</span></div><p class="api-docs__definition">

Defined in
[emitter/emitter.ts:31](https://github.com/BetterTyped/hyper-fetch/blob/993719ed/packages/sockets/src/emitter/emitter.ts#L31)

</p><div class="api-docs__section">

#### Parameters

</div>
<div class="api-docs__parameters">
<table>
<thead><tr><th>Name</th><th>Details</th></tr></thead>
<tbody><tr param-data="timeout"><td class="api-docs__param-name required">

#### timeout

`Required`

</td><td class="api-docs__param-type">

`number`

</td></tr></tbody></table></div><div class="api-docs__section">

#### Return

</div><div class="api-docs__returns">

```ts
Emitter<RequestDataType, ResponseDataType, ClientType, MappedData>;
```

</div><hr/></div></div>
